package submarines.notices;

import submarines.Player;
import submarines.PlayerManager;

/**
 *
 * @author elad + shiran
 * 
 * This class will manage any notifications sent to the different players and they will
 * read them whenever they want.
 * 
 */
public class NotficationManager {

    protected PlayerManager pmanager;
    
    public NotficationManager(PlayerManager p) {
        pmanager = p;
    }
    
    /*
     * Notifies a single user
     */
    public void notifyUser(Player destination, Notice notice) {
        destination.addNotice(notice);
    }
    
    /*
     * Notifies everyone except s and d whih are the one that did the action (s) and the one
     *  the action was made on (d)
     */
    public void spreadTheWord(Player s, Player d, Notice n) {
        Player p;
        int i;
        
        for (i = 0; i < pmanager.numPlayersLeft(); i++) {
            p = pmanager.getNextPlayer();
            if ((p != s) && (p != d))
                p.addNotice(n);
        }
    }
}
